package cn.autoOffice.controller;
/*
 *功能说明：报销表控制层
 *@author 皮永浪
 *@Date 2023/3/29 11:03
 */

import cn.autoOffice.bean.pojo.Reimburse;
import cn.autoOffice.service.ReimburseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("reimburse")
public class ReimburseController {

    @Autowired
    private ReimburseService reimburseService;

    //根据员工工号查询报销单
    @PostMapping("findReimburse")
    // @RequiresRoles("financeUser")
    public List<Reimburse> findReimburseInfoBySubmitter(String submitter){
        List<Reimburse> reimburse = reimburseService.findReimburseBySubmitter(submitter);
        return reimburse;
    }

    //添加报销信息  apiJump/Reimburse/addReimburse
    @PostMapping("addReimburse")
    @ResponseBody
    public String addReimburse(@RequestBody Reimburse reimburse){
        boolean i = reimburseService.addReimburseInfo(reimburse);
        if (i) {
            return "0000:报销成功";
        }else {
            return "0001:报销失败";
        }
    }
}
